<template>
  <div class="app">
    <div>
      <itemBox title="本周学校光盘行动排行">
        <div class="rank">
          <div
            :class="[isActive === 'firstTen' ? 'active' : 'five']"
            @click="changeActive('firstTen')"
          >
            光盘行动前10学校
          </div>

          <div
            :class="[isActive === 'lastTen' ? 'active' : 'five']"
            @click="changeActive('lastTen')"
          >
            光盘行动后10学校
          </div>
        </div>
        <div class="chuyu">
          <div style="margin-right: 12px">全市日人均厨余:</div>
          <div class="chuyuBg">
            <countTo
              ref="countTo"
              :start-val="0"
              :end-val="3"
              :duration="3600"
            ></countTo>
          </div>
          <div style="font-family: LESLIE; font-size: 30px; color: #01dada">
            .
          </div>
          <div class="chuyuBg">
            <countTo
              ref="countTo"
              :start-val="0"
              :end-val="5"
              :duration="3600"
            ></countTo>
          </div>
          <div class="chuyuBg">
            <countTo
              ref="countTo"
              :start-val="0"
              :end-val="9"
              :duration="3600"
            ></countTo>
          </div>
          <div style="margin-left: 16px; color: rgba(255, 255, 255, 0.85)">
            g
          </div>
        </div>
        <table-scroll-pro
          v-if="isActive == 'firstTen'"
          :data="tableDataA"
          :columns="columnsA"
          :class-option="classOption2"
          :config="tablConfig2"
        ></table-scroll-pro>
        <table-scroll-pro
          v-if="isActive == 'lastTen'"
          :data="tableDataB"
          :columns="columnsA"
          :class-option="classOption"
          :config="tablConfig"
        ></table-scroll-pro>
      </itemBox>
    </div>
    <div style="margin-top: 24px">
      <itemBox title="供应商月度考核排行" class="mt24">
        <div style="display: flex">
          <div class="total">
            <div
              style="display: flex; flex-direction: column; align-items: center"
            >
              <div>
                <span style="font-weight: bold; font-size: 24px; color: #01dada"
                  ><countTo
                    ref="countTo"
                    :start-val="0"
                    :end-val="11"
                    :duration="3600"
                  ></countTo
                ></span>
              </div>
              <div style="width: 123px; height: 22px; margin: 4px 0">
                90分以上 (家)
              </div>
              <div class="icon">
                <div class="icon2"></div>
              </div>
            </div>
          </div>
          <div class="total">
            <div
              style="display: flex; flex-direction: column; align-items: center"
            >
              <div>
                <span style="font-weight: bold; font-size: 24px; color: #01dada"
                  ><countTo
                    ref="countTo"
                    :start-val="0"
                    :end-val="3"
                    :duration="3600"
                  ></countTo
                ></span>
              </div>
              <div style="width: 123px; height: 22px; margin: 4px 0">
                70-90分 (家)
              </div>
              <div class="icon">
                <div class="icon2"></div>
              </div>
            </div>
          </div>
          <div class="total">
            <div
              style="display: flex; flex-direction: column; align-items: center"
            >
              <div>
                <span style="font-weight: bold; font-size: 24px; color: #01dada"
                  ><countTo
                    ref="countTo"
                    :start-val="0"
                    :end-val="2"
                    :duration="3600"
                  ></countTo
                ></span>
              </div>
              <div style="width: 123px; height: 22px; margin: 4px 0">
                70分以下 (家)
              </div>
              <div class="icon">
                <div class="icon2"></div>
              </div>
            </div>
          </div>
        </div>
        <div class="rank">
          <div
            :class="[isActive2 === 'firstFive' ? 'active' : 'five']"
            @click="changeActive2('firstFive')"
          >
            月度考核前5
          </div>

          <div
            :class="[isActive2 === 'lastFive' ? 'active' : 'five']"
            @click="changeActive2('lastFive')"
          >
            月度考核后5
          </div>
        </div>
        <table-scroll-pro
          v-if="isActive2 == 'firstFive'"
          :data="tableDataC"
          :columns="columnsB"
          :class-option="classOption"
          :config="tablConfig"
        >
        </table-scroll-pro>
        <table-scroll-pro
          v-if="isActive2 == 'lastFive'"
          :data="tableDataD"
          :columns="columnsB"
          :class-option="classOption"
          :config="tablConfig"
        ></table-scroll-pro>
      </itemBox>
    </div>
  </div>
</template>

<script>
import drawMixin from "@/utils/drawMixin";
import countTo from "vue-count-to";
import pageTitle from "../../components/pageTitle";
import itemBox from "../../components/itemBox";
import subTit from "../../components/subTit";

let mixin = new drawMixin();
export default {
  name: "index",
  components: { countTo, pageTitle, itemBox, subTit },
  mixins: [mixin],
  data() {
    return {
      isActive: "firstTen",
      isActive2: "firstFive",
      columnsA: [
        { label: "排名", prop: "rank", align: "center" },
        {
          label: "学校",
          prop: "name",
          align: "center",
          width: 180,
          showOverflowTooltip: true,
        },
        { label: "学生数/人", prop: "peopleNum", align: "center" },
        { label: "日人均厨余/g", prop: "data", align: "center" },
      ],
      tableDataA: [
        {
          rank: "NO.01",
          name: `东阳市第二实验小学`,
          peopleNum: "2967",
          data: "1.86",
        },
        {
          rank: "NO.02",
          name: `江北初中`,
          peopleNum: "1284",
          data: "4.16",
        },
        {
          rank: "NO.03",
          name: `横店中心小学`,
          peopleNum: "2983",
          data: "8.32",
        },
        {
          rank: "04",
          name: `吴宁五校`,
          peopleNum: "1928",
          data: "9.52",
        },
      ],
      tableDataB: [
        {
          rank: "04",
          name: `东阳市第二实验小学`,
          peopleNum: "2967",
          data: "1.86",
        },
        {
          rank: "NO.03",
          name: `江北初中`,
          peopleNum: "1284",
          data: "4.16",
        },
        {
          rank: "NO.02",
          name: `横店中心小学`,
          peopleNum: "2983",
          data: "8.32",
        },
        {
          rank: "NO.01",
          name: `吴宁五校`,
          peopleNum: "1928",
          data: "9.52",
        },
      ],
      columnsB: [
        {
          label: "排名",
          prop: "rank",
          align: "center",
          width: 60,
          showOverflowTooltip: true,
        },
        {
          label: "供应商",
          prop: "name",
          align: "center",
          width: 175,
          showOverflowTooltip: true,
        },
        {
          label: "得分",
          prop: "score",
          align: "center",
          width: 50,
          showOverflowTooltip: true,
        },
        {
          label: "学校考核分",
          prop: "schoolScore",
          align: "center",
          width: 70,
          showOverflowTooltip: true,
        },
        {
          label: "局端考核分",
          prop: "bureauScore",
          align: "center",
          showOverflowTooltip: true,
        },
      ],
      tableDataC: [
        {
          rank: "NO.01",
          name: `义乌市宏盛蔬菜配送有限公司`,
          score: "95",
          schoolScore: "92",
          bureauScore: "98",
        },
        {
          rank: "NO.02",
          name: `东阳市绿中绿蔬菜配送有限公司`,
          score: "90",
          schoolScore: "86",
          bureauScore: "94",
        },
        {
          rank: "NO.03",
          name: `东阳市广源蔬菜配送有限公司`,
          score: "88.5",
          schoolScore: "90",
          bureauScore: "87",
        },
        {
          rank: "04",
          name: `东阳市恒贸蔬菜配送有限公司`,
          score: "86",
          schoolScore: "88",
          bureauScore: "84",
        },
      ],
      tableDataD: [
        {
          rank: "NO.01",
          name: `东阳市宏盛农产品有限公司`,
          score: "85",
          schoolScore: "88",
          bureauScore: "82",
        },
        {
          rank: "NO.02",
          name: `东阳好拍档食品有限责任公司`,
          score: "84",
          schoolScore: "86",
          bureauScore: "82",
        },
        {
          rank: "NO.03",
          name: `东阳石湖蔬菜配送有限公司`,
          score: "83",
          schoolScore: "82",
          bureauScore: "84",
        },
        {
          rank: "04",
          name: `东阳鑫旺农业发展有限公司`,
          score: "82",
          schoolScore: "86",
          bureauScore: "78",
        },
        {
          rank: "05",
          name: `东阳市横店影视城农副产品批发有限公司`,
          score: "81",
          schoolScore: "83",
          bureauScore: "79",
        },
        {
          rank: "06",
          name: `东阳市绿晨蔬菜有限公司`,
          score: "80",
          schoolScore: "82",
          bureauScore: "78",
        },
      ],
      classOption2: {
        limitMoveNum: 4,
        singleHeight: 46, // 单步运动停止的高度(默认值0是无缝不停止的滚动)
        waitTime: 2000, // 单步停止等待时间(默认值1000ms)
      },
      tablConfig2: {
        rowHeight: 44 + "px",
      },
      classOption: {
        limitMoveNum: 4,
        singleHeight: 40, // 单步运动停止的高度(默认值0是无缝不停止的滚动)
        waitTime: 2000, // 单步停止等待时间(默认值1000ms)
      },
      tablConfig: {
        rowHeight: 37 + "px",
        // headerHeight: 38 + "px",
      },
      interval: null,
    };
  },
  mounted() {},

  methods: {
    changeActive(value) {
      this.isActive = value; // 点击时改变选中状态
    },
    changeActive2(value) {
      this.isActive2 = value; // 点击时改变选中状态
    },
  },
};
</script>

<style scoped lang="scss">
@font-face {
  font-family: "LESLIE";
  src: url("~@/assets/food/LESLIEB.TTF");
}
.app {
  width: 100%;
  height: 100%;
  .rank {
    display: flex;
    margin-bottom: 12px;
    color: #b6bbc6;
    cursor: pointer;
    justify-content: flex-end;
    .five {
      width: 216px;
      height: 32px;
      line-height: 32px;
      text-align: center;
      background: #0d2246;
      // border: 1px solid #09508a;
      border: 1px solid rgba(9, 80, 138, 1);
      border-radius: 4px;
      margin-right: 4px;
    }
  }
  .active {
    color: #abf1ff;
    width: 216px;
    height: 32px;
    line-height: 32px;
    background: #0d2246;
    text-align: center;
    border: 1px solid rgba(83, 226, 255, 1);
    border-radius: 4px;
    margin-right: 4px;
  }
  .chuyu {
    display: flex;
    font-size: 20px;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    .chuyuBg {
      width: 26px;
      height: 40px;
      font-size: 36px;
      margin-left: 6px;
      background-image: url("~@/assets/food/chuyu.png");
      background-size: cover;
      font-family: LESLIE;
      color: #aefaff;
      text-align: center;
    }
  }
  .total {
    display: flex;
    // margin: 18px 0;
    // align-items: center;
    .icon {
      margin: 8px 10px 24px 0;
      width: 140px;
      height: 10px;
      background-color: #023351;
      .icon2 {
        width: 80px;
        height: 6px;
        background: #00baff;
        margin: 2px 0 0 1px;
      }
    }
  }
  .total:nth-child(2) .icon2 {
    width: 51px;
    height: 6px;
    background-color: #00fffa; /* 第二个 .total 的 icon 颜色为黄色 */
  }

  .total:nth-child(3) .icon2 {
    width: 97px;
    height: 6px;
    background-color: #f59a23; /* 第三个 .total 的 icon 颜色为红色 */
  }
}
</style>
